package com.oa.system.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.oa.system.entity.UserInfo;

/*
 * 查找用户信息*/
@Repository
public interface UserInfoDao extends PagingAndSortingRepository<UserInfo, Long>, JpaSpecificationExecutor<UserInfo> {
	UserInfo findByFullname(String name);

	@Query("from UserInfo u where u.dept.id = ?1")
	List<UserInfo> findByDeptId(Long id);

	@Query("select count(*) from UserInfo u where u.dept.id = ?1")
	int countByDeptId(Long id);

	@Query("from UserInfo u where u.role.id = ?1")
	List<UserInfo> findByRoleId(Long id);

	@Query("from UserInfo u where u.role.role = ?1")
	List<UserInfo> findByRoleName(String roleName);
}
